#ifndef IVERTEXBUFFER_H_INCLUDED
#define IVERTEXBUFFER_H_INCLUDED

#include "GLOBAL.h"
#include "Vertex.h"

/// IVertexBuffer Infromation
class IVertexBuffer {
protected:
	static const long m_DefaultFlags = eDBF_VRAM | eDBF_STATIC;

	uint		m_uiLength;		      ///< Buffer length
	long  	m_lFlags;		      ///< Buffer Usage Flags
	int  	 	m_iFormat;		      ///< Buffer Format
	ui16     m_usVertexSize;      ///< Size of one vertex in bytes
	byte*		m_RAMData;		      ///< Data in RAM
	int      m_Offset[4];         ///< Data offsets
	int      m_iPrimitiveType;    ///< Type of drawn primitives
	int      m_iInternalPrimitive;///< Video Driver internal primitive format

	#ifdef TZM_BUILD_SAFEMODE
		bool m_bInvalid;        ///< If this is true, the buffer is invalid and will not function
	#endif
private:

public:
	#ifdef TZM_BUILD_SAFEMODE
		bool IsInvalid( ) const { return m_bInvalid; }
	#endif

   uint  GetLength( )   const { return m_uiLength; }
   long  GetFlags( )    const { return m_lFlags;   }
   int   GetFormat( )   const { return m_iFormat;  }
   ui16  GetSize( )     const { return m_usVertexSize; }
   int   GetType( )     const { return m_iPrimitiveType; }
   int   GetInternalType( ) const { return m_iInternalPrimitive; }

	virtual void Bind( ui16 stage = 0 ) = 0;

	virtual void Draw( VERTEX_PRIMITIVE_TYPE type, uint start = 0, uint length = 0 ) = 0;
	virtual void DrawIndexed( VERTEX_PRIMITIVE_TYPE type, IVertexBuffer* indices, uint start = 0, uint length = 0 ) = 0;
	virtual void DrawInstanced( VERTEX_PRIMITIVE_TYPE type, uint start, uint length, IVertexBuffer* instances ) = 0;
	virtual void DrawIndexedInstanced( VERTEX_PRIMITIVE_TYPE type, IVertexBuffer* indices, uint start, uint length, IVertexBuffer* instances ) = 0;

	virtual void Draw( ) = 0;
	virtual void DrawIndexed( IVertexBuffer* indices ) = 0;
	virtual void DrawInstanced( IVertexBuffer* instances ) = 0;
	virtual void DrawIndexedInstanced( IVertexBuffer* indices, IVertexBuffer* instances ) = 0;

			   // IVertexBuffer Constructor & Virtual Destructor
			   IVertexBuffer( VERTEX_PRIMITIVE_TYPE type, uint length, byte* data, int format, int flags = eDBF_DEFAULT_SETTINGS )
			   : m_uiLength( length ), m_lFlags( flags ), m_iFormat( format ), m_usVertexSize( 0 ), m_RAMData( NULL ), m_iPrimitiveType(type)
			   #ifdef TZM_BUILD_SAFEMODE
					, m_bInvalid( true )
				#endif
				{
					if ( m_lFlags == eDBF_DEFAULT_SETTINGS )
						m_lFlags = m_DefaultFlags;
					if ( m_lFlags & eDBF_RAM )
						m_RAMData = data;
				}

	virtual ~IVertexBuffer( );
};


#endif // IVERTEXBUFFER_H_INCLUDED
